const _ = require('lodash');

const arr = [
  { id: 1, name: 'John' },
  { id: 2, name: 'Jane' },
  { id: 3, name: 'John' },
  { id: 4, name: 'Jane' },
  { id: 5, name: 'Mike' }
];

const grouped = _.groupBy(arr, 'name');
console.log(grouped);
